/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DatabasePack;

import org.apache.derby.client.am.PreparedStatement;
import java.util.Date;
import java.util.Date;
/**
 *
 * @author abdosalah
 */
public class Transaction {

    private String atm_id;
    private int client_id;
    private String date;
    private String time;
    private int money;
    private String kind_interaction;

    public boolean Addtransaction(String atm_id, int client_id, String date, String time, int money, String kind_interaction) {
        String sql = "insert into TRANSACTI(CLIENT_ID,MONEY,DATE,TIME,KIND_OF_TRANSACTION,ATM_ID) values(?,?,?,?,?,?)";
         
        java.sql.PreparedStatement ptmt = null;
        try{
            ptmt =DatabaseConnection.connection.prepareStatement(sql);
            ptmt.setInt(1, client_id);
            ptmt.setInt(2, money);
            ptmt.setString(3, date);
            ptmt.setString(4, time);
            ptmt.setString(5, kind_interaction);
            ptmt.setString(6, atm_id);
            ptmt.executeUpdate();
            return true;
        } catch (Exception e) {
            System.out.println("INSERT  function transaction class");
            e.printStackTrace();
          
            return false;
        }  
    }

    public boolean Addtransaction(String atm_id, int client_id, String  date, String time, int money, int reciever_id) {
          String sql = "insert into TRANSACTI values(?,?,?,?,?,?,?)";
         
        java.sql.PreparedStatement ptmt = null;
        try{
            ptmt =DatabaseConnection.connection.prepareStatement(sql);
            ptmt.setInt(1, client_id);
            ptmt.setInt(2, reciever_id);
            ptmt.setInt(3, money);
            ptmt.setString(4, date);
            ptmt.setString(5, time);
            ptmt.setString(6, "transfer");
            ptmt.setString(7, atm_id);
            ptmt.executeUpdate();
            return true;
        } catch (Exception e) {
            System.out.println("INSERT  function transaction class");
            e.printStackTrace();
          
            return false;
        }  
    }
}
